# peppy Copyright (c) 2006-2008 Rob McMullen
# Licenced under the GPLv2; see http://peppy.flipturn.org for more info
"""GDAL plugin.

This plugin adds GDAL support (http://www.gdal.org/) to the hyperspectral image
viewing capabilities of peppy.
"""

import os

from peppy.yapsy.plugins import *


class GDALPlugin(IPeppyPlugin):
    """When activated, adds GDAL to the list of hyperspectal image format
    loaders.
    """
    def activateHook(self):
        try:
            import GDAL
            import peppy.hsi.common as HSI
            HSI.HyperspectralFileFormat.addDefaultHandler(GDAL.GDALDataset)
        except ImportError:
            self.is_activated = False

    def deactivateHook(self):
        import GDAL
        import peppy.hsi.common as HSI
        HSI.HyperspectralFileFormat.removeHandler(GDAL.GDALDataset)
